import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:hc_bot_pro/common/tool/string_ex.dart';
import 'package:hc_cure_sdk_flutter/model/cure/cure.dart';

import '../../common/routes.dart';
import '../controller.dart';

class Cell extends StatelessWidget {
  final Cure cure;
  const Cell({super.key, required this.cure});

  @override
  Widget build(BuildContext context) {
    final theme = Get.theme;

    final channel = Get.find<CureController>().channel;
    return InkWell(
      borderRadius: BorderRadius.circular(5.sp),
      focusColor: theme.primaryColor.withAlpha(128),
      autofocus: true,
      onTap: () {
        final param = {
          "schemeId": cure.id,
          "duration": cure.durationInMinutes,
          "subject": cure.name,
        };

        Get.toNamed(Routes.kPlayer, arguments: param);
      },
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(5.sp),
          color: channel == null
              ? Colors.white.withOpacity(0.5)
              : channel!.appStyle.colors.pickCardBackColor.toColor(),
        ),
        alignment: Alignment.center,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            CircleAvatar(
              foregroundImage: CachedNetworkImageProvider(cure.logo),
              radius: 45.sp,
            ),
            Container(height: 5.sp),
            Text(
              cure.name,
              style: TextStyle(
                fontSize: 15.sp,
                color: channel == null
                    ? Colors.white
                    : channel!.appStyle.colors.pickCardNameColor.toColor(),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
